package com.vf.cloud.paas.app.master.api.file.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.vf.cloud.paas.app.master.api.file.service.IModelFile;
import com.vf.cloud.paas.app.master.common.repository.base.ModelFile;

import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@RestController
public class ModelFileController {

	
	@Autowired
	private IModelFile modelFileImpl;

	@GetMapping(value = "/api/v1/model/{id}", produces = { MediaType.IMAGE_JPEG_VALUE, MediaType.IMAGE_PNG_VALUE })
	@ResponseBody
	public byte[] image(@PathVariable String id) {
		byte[] data = null;
		ModelFile modelFile = modelFileImpl.findById(id);
		if (modelFile != null) {
			data = modelFile.getContent().getData();
		}
		return data;
	}

	
}
